package com.sugar.service.system.privilege;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sugar.base.query.PageModel;
import com.sugar.domain.system.privilege.PrivilegeResourceItem;
import com.sugar.persistence.system.privilege.IPrivilegeResourceItem;

@Service
public class PrivilegeResourceItemServiceBean implements IPrivilegeResourceItemService {
	
	@Resource
	private IPrivilegeResourceItem pridao ;

	@Override
	public void deletePrivilegeResourceItemService(int id) {
		this.pridao.deletePrivilegeResourceItemDao(this.loadPrivilegeResourceItemByIdService(id)) ;
	}

	@Override
	public void deleteSelectPrivilegeResourceItemService(Object[] ids) {
		this.pridao.deleteSelectPrivilegeResourceItemDao(ids) ;
	}

	@Override
	public List<PrivilegeResourceItem> findPrivilegeResourceItemService(
			Object[] param) {
		String queryString = "select o from PrivilegeResourceItem o" ;
		StringBuffer whereString = null ;
		if(null != param && param.length > 0) {
			whereString = new StringBuffer() ;
			whereString.append("ml_id=?") ;
		}
		
		return this.pridao.findPrivilegeResourceItemDao(queryString, whereString.toString(), param, null) ;
	}

	@Override
	public PageModel<PrivilegeResourceItem> getScorllPrivilegeResourceItemService(
			Object[] param, int firstPage, int pageSize) {
		String queryString = "select o from PrivilegeResourceItem o" ;
		return this.pridao.getScorllPrivilegeResourceItemDao(queryString, null, param, firstPage, pageSize, null) ;
	}

	@Override
	public PrivilegeResourceItem loadPrivilegeResourceItemByIdService(int id) {
		
		return this.pridao.loadPrivilegeResourceItemByIdDao(id) ;
	}

	@Override
	public void savePrivilegeResourceItemService(PrivilegeResourceItem pri)
			throws RuntimeException {
		this.pridao.savePrivilegeResourceItemDao(pri) ;
	}

	@Override
	public void updatePrivilegeResourceItemService(PrivilegeResourceItem pri) {
		this.pridao.updatePrivilegeResourceItemDao(pri) ;
	}

}
